package com.jdiv.samples.tutor4;

import com.jdiv.JDiv;
import com.jdiv.JProgram;

/**
 * @author  Joyal
 */
public class Main extends JProgram{
static int
	worm_length=8;  // Variables for topscore and score

static int apples=0;

static int score=0;

static int topscore=0;

/**
 * @uml.property  name="father"
 * @uml.associationEnd  
 */
static WormHead father;

	public Main(){
		
		JDiv.set_mode(JDiv.m320x200);
	    JDiv.load_fpg("res/fpg/tutor4.fpg");    // Loads graphics' file
	    JDiv.put_screen(1,1);                    // Puts background screen

	    // Puts score and topscore texts
	    JDiv.write(0,64,8,0,score);
	    JDiv.write(0,256,8,0,topscore);

	    // Creates worm head which controls the rest of the body
	    father=new WormHead(8,96,8,0);

	    System.out.println("PIXEL: "+JDiv.get_pixel(10,10));
	}                                
	 public void loop(){   
	        // Enters an endless loop
	        // Shows everything on screen
	        // An apple is printed randomly
	        // or not at all, but always while there are less than 3 apples
	        if (JDiv.rand(0,32)==0 && apples<3){
	            // Puts an apple and increments apples' counter
	           new Apple(JDiv.rand(1,38)*8,JDiv.rand(3,23)*8);
	            apples++;
	      	}
	}
	 
	public static void main(String[] args) {
		Main main=new Main();
	}

}
